﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Office.Interop.Excel;

namespace Battleship
{

    public class ContainerInfo
    {
        public string Name;
        public string Type;
        public int Size;
        public Port POO;
        public Port POD;
        public double Weight;
        public string COM;

        public Cor LCor;
        public Cor GCor;

        public bool isLoaded;
        public bool isTail;
        public Moment moment;

        public bool isCorrupted;

        public int no;

        public ContainerInfo()
        {
            Name = "";
            Type = "";
            Size = 0;
            POO = new Port();
            POD = new Port();
            Weight = 0;
            COM = "";
            LCor = new Cor();
            GCor = new Cor();
            isLoaded = false;
            isTail = false;
            moment = new Moment();
            no = 0;
            isCorrupted = false;
        }
        public ContainerInfo(int iNo, string iName, string iType, int iSize, Port iPOO, Port iPOD, float iWeight, string[] iCenter, string iCOM)
        {
            Name = iName;
            Type = iType;
            Size = iSize;
            POO = iPOO;
            POD = iPOD;
            Weight = iWeight;
            COM = iCOM;
            LCor = new Cor(iCenter);
            GCor = new Cor();
            isLoaded = false;
            isTail = false;
            valMoment();
            no = iNo;
        }
        public ContainerInfo(int iNo, List<string> dataList, PortList portList)
        {
            Name = dataList.ElementAt(0);
            Type = dataList.ElementAt(1);
            Size = int.Parse(dataList.ElementAt(2));

            POO = portList.findPortByName(dataList.ElementAt(3));

            POD = portList.findPortByName(dataList.ElementAt(4));

            Weight = float.Parse(dataList.ElementAt(5));
            COM = dataList.ElementAt(7);

            // cor
            string corStr = dataList.ElementAt(6);
            char[] delimiterChars = { ',' };
            string[] corSplited = corStr.Split(delimiterChars);
            LCor = new Cor(corSplited);
            GCor = new Cor();
            isLoaded = false;
            isTail = false;
            moment = new Moment();
            no = iNo;
        }
        public Moment valMoment()
        {
            double xm = this.GCor.x * 6.1 + this.LCor.x * 6.1;
            double ym = this.GCor.y * 2.44 + this.LCor.y * 2.44;
            double zm = this.GCor.z * 2.44 + this.LCor.z * 2.44;
            //if (isTail == true)
            //{
            //    moment = new Moment(0,0,0);
            //}
            //else
            {
                moment = new Moment(xm, ym, zm);
            }
            return moment;
        }
    }
}
